<!DOCTYPE html>
<html>
<head>
    <title>${sysEn}-配件保养类别编辑</title>
     <#include "/common/com_edit_css.ftl" >
</head>
<body>
    <div class="wrapper wrapper-content fadeInRight commoneditpage">
        <div class="row">
            <div class="col-lg-8 m-auto">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>${actNm}-用户信息</h5>
                    </div>
                    <div class="ibox-content">
                        <input type="hidden" id="typeInfo" value="${obj.type}">
                        <form id="form" action="${ctx}/cms_user_edit_sub.do" method="post">
                            <input type="hidden" name="id" id="id" value="${obj.id}">
                            <div class="form-group row"><label class="col-lg-2 col-form-label">用户名称：</label>
                                <div class="col-lg-10">
                                    <input type="text" placeholder="用户名"
                                           value="${obj.userName}" ${closeFlg}
                                           id="userName" name="userName" class="form-control"
                                           data-easyform="length:2 16;real-time;"
                                           data-message="用户名为长度[2-16]字符"
                                            />
                                </div>
                            </div>
                            <div class="form-group row"><label class="col-lg-2 col-form-label">密码：</label>
                                <div class="col-lg-10">
                                    <input type="password" placeholder="密码"
                                           id="password" name="password" class="form-control"
                                           data-easyform="null;regex:[a-zA-Z0-9]{6,16};"
                                           data-message="密码为长度[6-16]字符"
                                    />
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-lg-2 col-form-label must">状态：</label>
                                <div class="col-lg-10">
                                    <select name="status" id="status">
                                        <option value="0" <#if obj.status=0 >selected="selected"</#if>>停用</option>
                                        <option value="1" <#if obj.status=1 >selected="selected"</#if>>启用</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-lg-2 col-form-label">配置角色：</label>
                                <div class="col-lg-10">
                                    <table id="cForm" border="0" cellpadding="0" cellspacing="1">
                                        <tr>
                                            <th style="width: 50px;">&nbsp;</th>
                                            <th>角色名称</th>
                                        </tr>
                                        <#list obj.rolelist as cr>
                                            <tr>
                                                <td>
                                                    <input class="crCk"  data-easyform="null;" type="checkbox" <#if cr.active > checked="checked" </#if> value="${cr.id }">
                                                </td>
                                                <td>${cr.name}</td>
                                            </tr>
                                        </#list>
                                    </table>
                                </div>
                            </div>
                            <div class="form-group row ">
                                <div class="col-lg-offset-2 col-lg-10">
                                    <button class="btn btn-sm btn-primary" type="button" id="signBtn" tg="ensure">确定</button>
                                    <button class="btn btn-sm btn-white" type="button" id="cancelBtn" tg="cancel">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <#include "/common/com_edit_js.ftl">
    <script type="text/javascript">
        function roles(){
            var roles = "";
            $("#cForm").find("input[type=checkbox]").each(function () {
                roles += "," + $(this).val();
            });
            return roles;
        }
      $(document).ready(function () {
          if($("#typeInfo").val() && $("#typeInfo").val() == 0){
              ListPageManager.Popup.msg("系统用户不能修改",{},function () {
                  var index = parent.layer.getFrameIndex(window.name);
                  parent.layer.close(index);
                  parent.succflg = null;
              });
              return;
          }
            if(!$("#id").val()){
                $("#form").prop("action","/cms_user_add.do");
            }
            EditPager.init({
                container:$("#form"),
                param:function () {
                    var id = $("#id").val();
                    return {
                        id:id?id:0,
                        userName:$("#userName").val(),
                        password:$("#password").val(),
                        status:$("#status").val(),
                        roles:roles()
                    };
                }
            });
        });

    </script>
</body>
</html>
